package io.example.entity;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Description: Author.java .<br>
 * <p>Created Time: 2020/10/22 16:05 </p>
 *
 * @author <a href="mail to: mengxiangyuancc@gmail.com" rel="nofollow">孟祥元</a>
 */
@Data
@Entity
@DataObject(generateConverter = true)
public class Author {
    @Id
    @GeneratedValue
    private long id;

    private String name;

    public Author() {
    }

    public Author(JsonObject jsonObject) {
        AuthorConverter.fromJson(jsonObject, this);
    }

    public JsonObject toJson() {
        JsonObject json = new JsonObject();
        AuthorConverter.toJson(this, json);
        return json;
    }
}
